const mongoose = require('mongoose');
const Schema = mongoose.Schema;

const navHead = new Schema({
    'name': String,
    'route': String,
    'children': Array,
    'creationTime': String
})

const myInfo = new Schema({
    'portrait': String,
    'introduce': String,
    'mailbox': String,
    'mayun': String,
    'creationTime': String
})

const login = new Schema({
    'username': String,
    'role': String,
    'creationTime': String,
    'founder': String,
    'password': String,
    'roleId': {
        type: mongoose.Schema.Types.ObjectId, 
        ref: 'role'
    }
}, { versionKey: false })

const role = new Schema({
    'name': String,
    'juris': Array,
    'creationTime': String,
    'founder': String,
}, { versionKey: false })

const left_nav = new Schema({
    icon: String,
    name: String,
    children: Array
})

const blogMessage = new Schema({
    'name': String,
    'mailbox': String,
    'info': String,
    'children': Array,
    'type': Number,
    'creationTime': String
}, { versionKey: false })

const article = new Schema({
    'title': String,
    'browse': String,
    'label': String,
    'name': String,
    'type': Number,
    'creationTime': String,
    'info': String,
    'mold': Number,
    'mag': Array
},{ versionKey: false })

const articleMas = new Schema({
    'name': String,
    'mailbox': String,
    'info': String,
    'mag': Array,
    'type': Number,
    'creationTime': String
}, { versionKey: false })

const draft = new Schema({
    'name': String,
    'title': String,
    'info': String,
    'creationTime': String
}, { versionKey: false })

module.exports = {
    navHead: mongoose.model('nav-head', navHead, 'head_nav'),
    myInfo: mongoose.model('my-info', myInfo, 'my_info'),
    login: mongoose.model('login', login, 'admin_user'),
    role: mongoose.model('role', role, 'admin_role'),
    left_nav: mongoose.model('left_nav', left_nav, 'admin_left_nav'),
    blogMessage: mongoose.model('blogMessage', blogMessage, 'blog_message'),
    article: mongoose.model('article', article, 'article_list'),
    articleMas: mongoose.model('articleMas', articleMas, 'article_message'),
    draft: mongoose.model('draft', draft, 'admin_draft')
}